package rad.framework.mda.generator.template.main.webapp;

import org.eclipse.uml2.uml.*;
import java.util.*;
import rad.framework.mda.generator.util.*;

public class Page
{
  protected static String nl;
  public static synchronized Page create(String lineSeparator)
  {
    nl = lineSeparator;
    Page result = new Page();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<ui:composition xmlns=\"http://www.w3.org/1999/xhtml\"" + NL + "\txmlns:ui=\"http://java.sun.com/jsf/facelets\"" + NL + "\txmlns:h=\"http://java.sun.com/jsf/html\"" + NL + "\txmlns:f=\"http://java.sun.com/jsf/core\"" + NL + "\txmlns:c=\"http://java.sun.com/jstl/core\"" + NL + "\txmlns:rich=\"http://richfaces.ajax4jsf.org/rich\"" + NL + "\txmlns:a4j=\"https://ajax4jsf.dev.java.net/ajax\"" + NL + "\txmlns:t=\"https://code.google.com/p/rad-framework/taglib\"" + NL + "\txmlns:tt=\"https://code.google.com/p/rad-framework\"" + NL + "\txmlns:s=\"http://jboss.com/products/seam/taglib\"" + NL + "\ttemplate=\"#{theme.page}\">" + NL + "" + NL + "\t<ui:param name=\"page\" value=\"#{";
  protected final String TEXT_2 = "Page}\" />" + NL + "\t" + NL + "\t<ui:define name=\"content\">" + NL + "\t\tTODO - Place appropiate components here..." + NL + "\t</ui:define>" + NL + "\t" + NL + "\t<ui:define name=\"menus\">" + NL + "\t\t\t<ui:repeat value=\"#{page.menus}\" var=\"menu\">" + NL + "\t\t\t\t<tt:page-menu />" + NL + "\t\t\t</ui:repeat>" + NL + "\t</ui:define>" + NL + "\t" + NL + "\t<ui:define name=\"navButtons\">" + NL + "\t\t<ui:repeat value=\"#{page.actions}\" var=\"action\">" + NL + "\t\t\t<tt:page-action />" + NL + "\t\t</ui:repeat>" + NL + "\t</ui:define>" + NL + "\t" + NL + "</ui:composition>";
  protected final String TEXT_3 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    
State state = (State) argument;
Region region = (Region)state.getOwner();

    stringBuffer.append(TEXT_1);
    stringBuffer.append(NameHelper.removeSpaces(region.getName()));
    stringBuffer.append(NameHelper.getCapName(state));
    stringBuffer.append(TEXT_2);
    stringBuffer.append(TEXT_3);
    return stringBuffer.toString();
  }
}
